package fr.bda.cloud.data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

import fr.bda.cloud.storage.StorageUnitConfiguration;

/**
 * This class represent a data stored in cloud.
 * 
 * @author BARET
 * @since 11/11/2012
 * 
 */
@XmlRootElement(name = "descriptor")
public class DataDescriptor {

	/** The storage mode */
	private StorageMode storageMode;

	private Date saveDate;

	private String owner;

	private String fileUuid;
	private String fileName;
	private Long fileSize;

	private Integer nbBlocs;
	private Long blocSize;
	private String blocUuid;

	private String dataUuid;
	private Long dataSize;

	private List<StorageUnitConfiguration> storageUnits = new ArrayList<>();

	@XmlElementWrapper(name = "storages")
	@XmlElement(name = "storage_unit")
	public List<StorageUnitConfiguration> getStorageUnits() {
		return storageUnits;
	}

	public void setStorageUnits(List<StorageUnitConfiguration> storageUnits) {
		this.storageUnits = storageUnits;
	}

	public StorageMode getStorageMode() {
		return storageMode;
	}

	public void setStorageMode(StorageMode storageMode) {
		this.storageMode = storageMode;
	}

	public String getOwner() {
		return owner;
	}

	public void setOwner(String owner) {
		this.owner = owner;
	}

	public String getFileUuid() {
		return fileUuid;
	}

	public void setFileUuid(String fileUuid) {
		this.fileUuid = fileUuid;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public Long getFileSize() {
		return fileSize;
	}

	public void setFileSize(Long fileSize) {
		this.fileSize = fileSize;
	}

	public Integer getNbBlocs() {
		return nbBlocs;
	}

	public void setNbBlocs(Integer nbBlocs) {
		this.nbBlocs = nbBlocs;
	}

	public Long getBlocSize() {
		return blocSize;
	}

	public void setBlocSize(Long blocSize) {
		this.blocSize = blocSize;
	}

	public String getBlocUuid() {
		return blocUuid;
	}

	public void setBlocUuid(String blocUuid) {
		this.blocUuid = blocUuid;
	}

	public String getDataUuid() {
		return dataUuid;
	}

	public void setDataUuid(String dataUuid) {
		this.dataUuid = dataUuid;
	}

	public Long getDataSize() {
		return dataSize;
	}

	public void setDataSize(Long dataSize) {
		this.dataSize = dataSize;
	}

	public Date getSaveDate() {
		return saveDate;
	}

	public void setSaveDate(Date saveDate) {
		this.saveDate = saveDate;
	}

	@Override
	public String toString() {
		return fileName + "[" + storageMode.name() + "] on " + storageUnits.size() + " storage units";
	}
}
